package com.wu.llpsw.data;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;

import java.util.Random;

public class tianFu {
    public static float addhealththis=1.0f;
    public static float addattackthis=1.0f;
    public static float addyuanlithis=1.0f;
    private static int level=1;//玩家的天赋

    public static int getLevel(){
        if (level>0){
            return level;
        }
        else {
            return -level;
        }
    }
    //设置玩家的天赋等级
    public static void setLevel(Player player,boolean newGame){
        //获取玩家数据包
        CompoundTag playerData = player.getPersistentData();
        //是新游戏
        if(newGame==true){
            //message.sendMessage(player,"欢迎加入荒古世界");
            //获取随机天赋
            Random random = new Random();
            level=random.nextInt(9) + 1;

            playerData.putFloat("addhealththis",1.0f);
            playerData.putFloat("addattackthis",1.0f);
            playerData.putFloat("addyuanlithis",1.0f);
            playerData.putInt("tianfu",level);
            //message.sendMessage(player,"战士!你拥有"+level+"级天赋");
        }
        else if(newGame==false){
            level=playerData.getInt("tianfu");
            addhealththis=playerData.getFloat("addhealththis");
            addattackthis=playerData.getFloat("addattackthis");
            addyuanlithis=playerData.getFloat("addyuanlithis");
            //message.sendMessage(player,"或许这不是你的第一次冒险了");
            //message.sendMessage(player,"战士!你拥有"+level+"级天赋");
        }
        levelData.setParam(player,player.experienceLevel);
    }



    public static void setadd(Player player,float health,float attack,float yuanli){
        addhealththis+=health;
        addattackthis+=attack;
        addyuanlithis+=yuanli;

        //获取玩家数据包
        CompoundTag playerData = player.getPersistentData();
        playerData.putFloat("addhealththis",addhealththis);
        playerData.putFloat("addattackthis",addattackthis);
        playerData.putFloat("addyuanlithis",addyuanlithis);
    }
}
